//引入路由组件
import Home from '@/views/Home'
import Search from '@/views/Search'
import Login from '@/views/Login'
import Register from '@/views/Register'
import Detail from '@/views/Detail'
import ShopCart from '@/views/ShopCart'
import AddCartSuccess from '@/views/AddCartSuccess'
import Trade from '@/views/Trade'
import Center from '@/views/Center'
import Pay from '@/views/Pay'
import PaySuccess from '@/views/PaySuccess'
export default [
    {
        path: "/paySuccess",
        component: PaySuccess,
        meta: { show: true },
        name: "paySuccess"
    },
    {
        path: "/center",
        component: Center,
        meta: { show: true },
        name: "center",
        redirect: '/center/myOrder',
        children: [
            {
                path: "/center/myOrder",
                meta: { show: true },
                name: "myOrder",
                component: () => import('@/views/Center/myOrder')
            },
            {
                path: "/center/groupOrder",
                meta: { show: true },
                name: "groupOrder",
                component: () => import('@/views/Center/groupOrder')
            }
        ]
    },
    {
        path: "/pay",
        component: Pay,
        meta: { show: true },
        name: "pay",
        beforeEnter: (to, from, next) => {
            if(from.path = '/trade'){
                next()
            }else {
                next(false)
            }
         }
    },
    {
        path: "/trade",
        component: Trade,
        meta: { show: true },
        name: "trade",
        beforeEnter: (to, from, next) => {
           if(from.path = '/shopcart'){
               next()
           }else {
               next(false)
           }
        }
    },
    {
        path: "/addCartSuccess",
        component: AddCartSuccess,
        meta: { show: true },
        name: "addCartSuccess"
    },
    {
        path: "/shopCart",
        component: ShopCart,
        meta: { show: true },
        name: "shopCart"
    },
    {
        path: "/detail/:skuid",
        component: Detail,
        meta: { show: true },
        name: "detail"
    },
    {
        path: "/home",
        component: Home,
        meta: { show: true },
        name: "home"
    },
    {
        path: "/search/:keyword?",
        component: Search,
        meta: { show: true },
        name: "search"
    },
    {
        path: "/login",
        component: Login,
        meta: { show: false },
        name: "login"
    },

    {
        path: "/register",
        component: Register,
        meta: { show: false },
        name: "register"
    },
]
